﻿<UserControl
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             x:Class="Bazookabird.Wpf.Queries.QueryHandlers.SimpleCmmiProcessTaskViewer.SimpleCmmiProcessTaskViewerView"
             mc:Ignorable="d" d:DesignHeight="330" d:DesignWidth="644"
    FontSize="{Binding FontSize}">
    <UserControl.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="/Queries\QueryHandlers\SimpleCmmiProcessTaskViewer\SimpleLayouts.xaml" />
            </ResourceDictionary.MergedDictionaries>
            <Style TargetType="{x:Type GridSplitter}">
                <Setter Property="Width" Value="5" />
                <Setter Property="Background" Value="Transparent" />
                <Setter Property="VerticalAlignment" Value="Stretch" />
                <Setter Property="ResizeBehavior" Value="PreviousAndNext" />
            </Style>
            <Style x:Key="ItemsControlWrapPanelStyle" TargetType="{x:Type ItemsControl}">
                <Setter Property="ItemsPanel">
                    <Setter.Value>
                        <ItemsPanelTemplate>
                            <WrapPanel />
                        </ItemsPanelTemplate>
                    </Setter.Value>
                </Setter>
            </Style>
            <Style TargetType="Border" x:Key="ContentBorder">
                <Setter Property="BorderBrush" Value="#34000000" />
                <Setter Property="CornerRadius" Value="4" />
                <Setter Property="BorderThickness" Value="1" />
            </Style>
            <Style TargetType="{x:Type TextBlock}" x:Key="Header">
                <Setter Property="FontWeight" Value="Bold" />
                <Setter Property="HorizontalAlignment" Value="Center" />
            </Style>

            <Style x:Key="ItemSettingStyle">
                <Setter Property="FrameworkElement.Width" Value="{Binding RelativeSource={RelativeSource AncestorType={x:Type UserControl}}, Path=DataContext.ItemWidth}" />
                <Setter Property="FrameworkElement.Height" Value="{Binding RelativeSource={RelativeSource AncestorType={x:Type UserControl}}, Path=DataContext.ItemHeight}" />                
            </Style>

        </ResourceDictionary>
    </UserControl.Resources>
    <UserControl.Template>
        <StaticResource ResourceKey="PanelTemplate"/>
    </UserControl.Template>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="*" />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="0.25*" MinWidth="5" />
            <ColumnDefinition Width="Auto" />
            <ColumnDefinition Width="0.25*" MinWidth="5"/>
            <ColumnDefinition Width="Auto" />
            <ColumnDefinition Width="0.25*" MinWidth="5"/>
            <ColumnDefinition Width="Auto" />
            <ColumnDefinition Width="0.25*" MinWidth="5"/>
        </Grid.ColumnDefinitions>

        <Border Grid.Column="0" Style="{StaticResource ContentBorder}">
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto" />
                    <RowDefinition />
                </Grid.RowDefinitions>
                <TextBlock Text="Proposed" Style="{StaticResource Header}" />
                <ItemsControl Grid.Row="1" ItemsSource="{Binding ProposedTasks}" Style="{StaticResource ItemsControlWrapPanelStyle}" ItemContainerStyle="{StaticResource ItemSettingStyle}" />
            </Grid>
        </Border>

        <GridSplitter Grid.Column="1" Grid.RowSpan="3" />

        <Border Grid.Column="2" Style="{StaticResource ContentBorder}">
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto" />
                    <RowDefinition />
                </Grid.RowDefinitions>
                <TextBlock Text="Active" Style="{StaticResource Header}" />
                <ItemsControl Grid.Row="1" ItemsSource="{Binding ActiveTasks}" Style="{StaticResource ItemsControlWrapPanelStyle}" ItemContainerStyle="{StaticResource ItemSettingStyle}" />
            </Grid>
        </Border>

        <GridSplitter Grid.Column="3" Grid.RowSpan="3" />

        <Border Grid.Column="4" Style="{StaticResource ContentBorder}">
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto" />
                    <RowDefinition />
                </Grid.RowDefinitions>
                <TextBlock Text="Resolved" Style="{StaticResource Header}"  />
                <ItemsControl Grid.Row="1" ItemsSource="{Binding ResolvedTasks}" Style="{StaticResource ItemsControlWrapPanelStyle}" ItemContainerStyle="{StaticResource ItemSettingStyle}" />
            </Grid>
        </Border>

        <GridSplitter Grid.Column="5" Grid.RowSpan="3" Width="2" />

        <Border Grid.Column="6" Style="{StaticResource ContentBorder}">
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto" />
                    <RowDefinition />
                </Grid.RowDefinitions>
                <TextBlock Text="Closed"  Style="{StaticResource Header}"  />
                <ItemsControl Grid.Row="1" ItemsSource="{Binding ClosedTasks}" Style="{StaticResource ItemsControlWrapPanelStyle}" ItemContainerStyle="{StaticResource ItemSettingStyle}" />
            </Grid>
        </Border>

        <StackPanel Grid.Row="2" Grid.ColumnSpan="7">
            <Label Foreground="DarkGray" Content="{Binding LastUpdated, FallbackValue='Never updated', StringFormat='Last updated: {0}'}" Height="25" HorizontalAlignment="Right"/>
        </StackPanel>
    </Grid>
</UserControl>
